package com.myrobot;

import java.awt.Point;
import java.util.Map;

import com.myrobot.model.PointModel;
import com.myrobot.ui.PointFrame;
import com.myrobot.ui.PointFrame.OnActionPointListener;
import com.myrobot.util.RobotUtil;

public class VuforiaKey {

	public static void main(String[] args) {
		boolean isBuildModel = false;
		if (isBuildModel) {
			PointFrame pointFrame = new PointFrame(
					new String[] { "add_target", "browse", "filename", "open", "width", "add" });
			pointFrame.setActionPointListener(new OnActionPointListener() {

				@Override
				public void finish(Map<String, Point> actionPoints) {
					// TODO Auto-generated method stub
					PointModel mode = new PointModel(actionPoints);
					System.out.println(mode.toString());
				}

				@Override
				public void cancel() {
					// TODO Auto-generated method stub

				}
			});
		} else {
			String names[] = new String[] { "low000", "low001", "low002", "low003", "low004",
					"low005", "low006", "low007", "low008", "low009", "low010", "low011",
					"low012", "low013", "low014", "low015", "low016", "low017", "low018",
					"low019" };
			PointModel model = new PointModel(
					"{\"add\":{\"x\":1160,\"y\":884},\"filename\":{\"x\":239,\"y\":478},\"width\":{\"x\":736,\"y\":613},\"add_target\":{\"x\":560,\"y\":494},\"open\":{\"x\":786,\"y\":509},\"browse\":{\"x\":1148,\"y\":501}}");
			for (String name : names) {
				RobotUtil.delay(2000);
				RobotUtil.leftMouseClick(model.getPoints().get("add_target"));
				RobotUtil.delay(1000);
				RobotUtil.leftMouseClick(model.getPoints().get("browse"));
				RobotUtil.delay(1000);
				RobotUtil.leftMouseClick(model.getPoints().get("filename"));
				RobotUtil.input(name + ".jpg");
				RobotUtil.delay(1000);
				RobotUtil.leftMouseClick(model.getPoints().get("open"));
				RobotUtil.delay(1000);
				RobotUtil.leftMouseClick(model.getPoints().get("width"));
				RobotUtil.delay(1000);
				RobotUtil.input("0.25");
				RobotUtil.delay(1000);
				RobotUtil.leftMouseClick(model.getPoints().get("add"));
				RobotUtil.delay(10 * 1000);
			}
		}
	}
}
